package edu.pku.dao;

import java.sql.SQLException;
import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;

import edu.pku.data.Depository;
import edu.pku.data.DepositoryShell;
import edu.pku.util.MySqlMapClient;

public class DepositoryShellDao {
	
	public void addDepositoryShell(DepositoryShell ds) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		sqlMap.insert("insert_depository_shell",ds);
	}
	
	public boolean isNameExist(Depository d,String name) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		List<String> list = sqlMap.queryForList("get_depository_shell_name",d);
		if(list.contains(name))
			return true;
		return false;
	}
	
	public List<DepositoryShell> getDepositoryShell(Depository d) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		List<DepositoryShell> list =  sqlMap.queryForList("get_depository_shells",d);
		return list;
	}
	
	public void deleteDepositoryShell(DepositoryShell ds) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		sqlMap.delete("delete_depository_shell",ds);
	}
	
	public void updateDepositoryShell(DepositoryShell ds) throws SQLException
	{
		SqlMapClient sqlMap = MySqlMapClient.getSqlMapInstance();
		sqlMap.update("update_depository_shell",ds);
	}
}
